﻿using System;

namespace ConsoleApp10
{
    internal class Program
    {
        static void Main(string[] args)
        {
            DateTime start = DateTime.Now;
            int i = 100000, k, judge=0, primenumber,end=0;
            for (int j = 1; j <= i; j++)//从1到100000
            {
                for (int factor = 1; factor <= j; factor++)//因数从1开始到其本身
                {
                    k = j % factor;
                    if (k == 0)//代表有一个因数
                    {
                        judge++;
                    }
                }
                if(judge<=2)//判断是否为质数
                {
                   primenumber = j;
                    end = end > primenumber ? end : primenumber;//寻找最大质数
                }
                judge = 0;
            }
            Console.WriteLine(end);
            DateTime finish = DateTime.Now;
            TimeSpan add= finish.Subtract(start);
            Console.WriteLine("寻找最大质数所需要的时间为{0}秒", add.TotalSeconds);
        }
    }
}